package Server.domain.threads;

import Server.domain.BomberManChatServer;
import Server.gui.BomberManServerGUI;

/**
 * Thread running the server
 * 
 * @author Michael Heughebaert <michael.heughebaert.r2449@student.hogent.be>
 */
public class BomberManChatServerThread extends Thread {
    private BomberManChatServer bmServer;
    private BomberManServerGUI bmServerGui;

    //Constructor with server and gui
    public BomberManChatServerThread(BomberManChatServer bmServer) {
        super("Bomberman Chat Server Thread");
        this.bmServer = bmServer;
    }
    
    @Override
    public void run() {
        //Start the server
        try{
        bmServer.start(); // should execute until if fails
        }
        catch(Exception e)
                {
        bmServerGui.getB_serverStartStop().setText("Start");
	bmServerGui.getTf_TCPPortNumber().setEditable(true);
        bmServerGui.getTf_UDPPortNumber().setEditable(true);
	bmServerGui.appendEvent("Server crashed\n");
	bmServer = null;
                }
    }  
}